﻿<UserControl x:Class="TwitualStudio.TwitualStudioUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             Name="MyToolWindow"
             Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}">
    <Control.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="TwitualStudioStyles.xaml" />
                <ResourceDictionary Source="SettingsStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Control.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition Height="*" />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>
        <DockPanel Grid.RowSpan="3" Background="{StaticResource MainControlBackground}">
            <Border Style="{StaticResource MainBorderStyle}">
                <DockPanel Margin="20">
                    <DockPanel DockPanel.Dock="Top">
                        <Button Name="btnClear" Style="{StaticResource ClearButtonStyle}" Content="Clear" Click="btnClear_Click"/>
                        <Button Name="btnRefresh" Style="{StaticResource RefreshButtonStyle}" Content="Refresh" Click="btnRefresh_Click" />
                        <TextBlock Style="{StaticResource TimelineTextStyle}" />
                    </DockPanel>
                    <ScrollViewer Margin="0,10,0,0">
                        <ListBox Name="lstTimeline" ItemContainerStyle="{StaticResource TweetsItemStyle}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <DockPanel MaxWidth="{Binding ElementName=lstTimeline, Path=ActualWidth}">
                                        <Border Margin="10" DockPanel.Dock="Left"  BorderBrush="White" BorderThickness="1" Height="48" Width="48" HorizontalAlignment="Center">
                                            <Image Source="{Binding User.ProfileImageUrl, IsAsync=True}" Height="48" Width="48" />
                                        </Border>
                                        <StackPanel Margin="10" DockPanel.Dock="Right">
                                            <TextBlock Text="{Binding User.Name}" FontWeight="Bold" FontSize="18" />
                                            <TextBlock Text="{Binding Text}" Margin="0,4,0,0" FontSize="14" Foreground="#c6de96" TextWrapping="WrapWithOverflow" />
                                            <TextBlock Text="{Binding CreatedDate}" FontSize="14" FontFamily="Georgia" FontStyle="Italic" Foreground="#BBB" />
                                        </StackPanel>
                                    </DockPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </ScrollViewer>
                </DockPanel>
            </Border>
        </DockPanel>
        <Border Style="{StaticResource SettingsWindowStyle}" Name="mainBorder" Grid.Row="1" Width="194" Height="187">
            <Border.Triggers>
                <EventTrigger SourceName="toggleSettings"  RoutedEvent="ToggleButton.Checked">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Duration="0:0:0.2" Storyboard.TargetProperty="Width" To="250" />
                            <DoubleAnimationUsingKeyFrames BeginTime="0:0:0.2" Duration="0:0:0.3" Storyboard.TargetProperty="Height">
                                <LinearDoubleKeyFrame Value="400" KeyTime="0:0:0.2" />
                                <LinearDoubleKeyFrame Value="420" KeyTime="0:0:0.24" />
                                <LinearDoubleKeyFrame Value="400" KeyTime="0:0:0.3" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <EventTrigger SourceName="toggleSettings" RoutedEvent="ToggleButton.Unchecked">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="Height">
                                <LinearDoubleKeyFrame Value="100" KeyTime="0:0:0.2" />
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetProperty="Width">
                                <LinearDoubleKeyFrame Value="40" KeyTime="0:0:0.2" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Border.Triggers>
            <Grid Margin="10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="10*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="20" />
                </Grid.ColumnDefinitions>
                <ToggleButton Style="{StaticResource ToggleButtonStyle}" Name="toggleSettings" Grid.ColumnSpan="3" HorizontalAlignment="Left" Checked="toggleSettings_Checked">
                    <TextBlock Text="Show Prefs"><TextBlock.LayoutTransform>
                            <RotateTransform Angle="-90"></RotateTransform>
                        </TextBlock.LayoutTransform>
                    </TextBlock>
                    <ToggleButton.ToolTip>
                        <ToolTip>
                            <TextBlock Padding="10" Background="White" Foreground="Black" Text="Show/Hide" />
                        </ToolTip>
                    </ToggleButton.ToolTip>
                </ToggleButton>
                <Rectangle Style="{StaticResource RectangleDividerStyle}" />
                <DockPanel Grid.Column="0" Margin="0,2,0,2" Background="#33FFFFFF">
                    <TextBlock Style="{StaticResource SettingsHeadingStyle}" />
                    <StackPanel DockPanel.Dock="Top" Margin="0,10,0,0">
                        <TextBlock Style="{StaticResource SettingsTextBlockStyle}" Text="OAuth PIN">
                        </TextBlock>
                        <Button x:Name="btnGetOAuthPin" Content="Get PIN" Style="{StaticResource SettingsButtonStyle}" Click="btnGetOAuthPin_Click"/>
                        <TextBox Style="{StaticResource SettingsTextBoxStyle}" Name="txtOAuthPIN" KeyUp="txtOAuthPIN_KeyUp"/>
                        <Button x:Name="btnSettingsSave" Content="Save &amp; Refresh" Style="{StaticResource SettingsButtonStyle}" Click="btnSettingsSave_Click"/>
                    </StackPanel>
                </DockPanel>
            </Grid>
        </Border>
    </Grid>
</UserControl>
